﻿<UserControl x:Class="EasyInvoice.WPF.Content.ClientListNew"
			 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
			 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
			 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
			 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
			 xmlns:mui="http://firstfloorsoftware.com/ModernUI"
			 xmlns:vm="clr-namespace:EasyInvoice.WPF.ViewModel"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
>
	<UserControl.DataContext>
		<vm:ClientListNewViewModel/>
	</UserControl.DataContext>
	<Grid>
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
			<RowDefinition Height="*"/>
		</Grid.RowDefinitions>


        <TextBlock Grid.Row="0" Text="Client List " Style="{StaticResource Heading1}" Margin="0,0,0,8" />
        <StackPanel Grid.Row="1" VerticalAlignment="Center"  Margin=" 0,-8,0,0">
            
            <DockPanel DockPanel.Dock="Right" HorizontalAlignment="Right">
                <TextBlock Text="filters:" Margin="8,0,0,0" VerticalAlignment="Center"/>
                <TextBlock Text="name" Margin="8,0,3,0" VerticalAlignment="Center"/>
                <TextBox MinWidth="100" Text="{Binding Name,UpdateSourceTrigger=PropertyChanged}">
                    <TextBox.InputBindings>
                        <KeyBinding Key="Enter" Command="{Binding RefreshCommand}" />
                    </TextBox.InputBindings>
                </TextBox>
                <CheckBox Content="can issue invoices" Margin="8,0,3,0"  IsThreeState="True" IsChecked="{Binding CanIssueInvoices,UpdateSourceTrigger=PropertyChanged}" />
                <mui:ModernButton EllipseDiameter="24" IconWidth="14" IconHeight="14" Margin="8,0,3,0"
							x:Name="searchModernButton"
							IconData="M 34.8333,61.75L 34.8333,42.75L 19,20.5833L 57,20.5833L 41.1667,42.75L 41.1667,58.5833L 34.8333,61.75 Z "
							Command="{Binding RefreshCommand}"
							ToolTip="filter clients"/>
            </DockPanel>
            <!--<DockPanel DockPanel.Dock="Left" HorizontalAlignment="Left">
                <mui:ModernButton EllipseDiameter="24" IconWidth="14" IconHeight="14"
							x:Name="addModernButton"
							IconData="M 20.5833,20.5833L 55.4167,20.5833L 55.4167,55.4167L 45.9167,55.4167L 45.9167,44.3333L 30.0833,44.3333L 30.0833,55.4167L 20.5833,55.4167L 20.5833,20.5833 Z M 33.25,55.4167L 33.25,50.6667L 39.5833,50.6667L 39.5833,55.4167L 33.25,55.4167 Z M 26.9167,23.75L 26.9167,33.25L 49.0833,33.25L 49.0833,23.75L 26.9167,23.75 Z "
							Command="{Binding ShowSaveCommand}"
							ToolTip="save client"/>
                <mui:ModernButton 
							x:Name="deleteModernButton" EllipseDiameter="24" IconWidth="14" IconHeight="14"
							IconData="M 25.3333,23.75L 50.6667,23.75C 51.5411,23.75 51.8541,27.3125 51.8541,27.3125L 24.1458,27.3125C 24.1458,27.3125 24.4589,23.75 25.3333,23.75 Z M 35.625,19.7917L 40.375,19.7917C 40.8122,19.7917 41.9583,20.9378 41.9583,21.375C 41.9583,21.8122 40.8122,22.9584 40.375,22.9584L 35.625,22.9584C 35.1878,22.9584 34.0416,21.8122 34.0416,21.375C 34.0416,20.9378 35.1878,19.7917 35.625,19.7917 Z M 27.7083,28.5L 48.2916,28.5C 49.1661,28.5 49.875,29.2089 49.875,30.0834L 48.2916,53.8334C 48.2916,54.7078 47.5828,55.4167 46.7083,55.4167L 29.2917,55.4167C 28.4172,55.4167 27.7083,54.7078 27.7083,53.8334L 26.125,30.0834C 26.125,29.2089 26.8339,28.5 27.7083,28.5 Z M 30.0833,31.6667L 30.4792,52.25L 33.25,52.25L 32.8542,31.6667L 30.0833,31.6667 Z M 36.4167,31.6667L 36.4167,52.25L 39.5833,52.25L 39.5833,31.6667L 36.4167,31.6667 Z M 43.1458,31.6667L 42.75,52.25L 45.5208,52.25L 45.9167,31.6667L 43.1458,31.6667 Z "
							Command="{Binding ShowDeleteCommand}"
							ToolTip="delete client"/>
                
                <mui:ModernButton 
							x:Name="refreshModernButton" EllipseDiameter="24" IconWidth="14" IconHeight="14"
							IconData="M 38,20.5833C 42.9908,20.5833 47.4912,22.6825 50.6667,26.046L 50.6667,17.4167L 55.4166,22.1667L 55.4167,34.8333L 42.75,34.8333L 38,30.0833L 46.8512,30.0833C 44.6768,27.6539 41.517,26.125 38,26.125C 31.9785,26.125 27.0037,30.6068 26.2296,36.4167L 20.6543,36.4167C 21.4543,27.5397 28.9148,20.5833 38,20.5833 Z M 38,49.875C 44.0215,49.875 48.9963,45.3932 49.7703,39.5833L 55.3457,39.5833C 54.5457,48.4603 47.0852,55.4167 38,55.4167C 33.0092,55.4167 28.5088,53.3175 25.3333,49.954L 25.3333,58.5833L 20.5833,53.8333L 20.5833,41.1667L 33.25,41.1667L 38,45.9167L 29.1487,45.9167C 31.3231,48.3461 34.483,49.875 38,49.875 Z "
							Command="{Binding RefreshCommand}" 
							ToolTip="refresh"/>
            </DockPanel>-->
        </StackPanel>
        <DataGrid Grid.Row="2"  
                  AutoGenerateColumns="False"
                  ItemsSource="{Binding Clients}"
                  SelectedItem="{Binding SelectedClient}" 
                  SelectionMode="Single" 
                  >
            <!--CanUserAddRows="{Binding CanAddClient, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="{Binding CanEditClient, UpdateSourceTrigger=PropertyChanged}"-->
                  <!--CanUserDeleteRows="{Binding CanDeleteClient,UpdateSourceTrigger=PropertyChanged}"-->
                   
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="RowEditEnding">
                    <i:InvokeCommandAction Command="{Binding ShowSaveCommand}"
                            CommandParameter="{Binding}"/>
                                           <!--Command="{Binding ShowSaveCommand}"/>-->
                </i:EventTrigger>
            </i:Interaction.Triggers>
            <DataGrid.InputBindings>
                <KeyBinding Key="Delete" Command="{Binding ShowDeleteCommand}" />
            </DataGrid.InputBindings>
            <DataGrid.Columns>
                <mui:DataGridTextColumn Header="Name" Binding="{Binding Name,UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"/>
                <mui:DataGridTextColumn Header="Address" Binding="{Binding Address, UpdateSourceTrigger=PropertyChanged,ValidatesOnDataErrors=True}"/>
                <mui:DataGridTextColumn Header="Postal Code" Binding="{Binding PostalCode, UpdateSourceTrigger=PropertyChanged}"/>
                <mui:DataGridTextColumn Header="City" Binding="{Binding City, UpdateSourceTrigger=PropertyChanged,ValidatesOnDataErrors=True}"/>
                <mui:DataGridTextColumn Header="State" Binding="{Binding State, UpdateSourceTrigger=PropertyChanged}"/>
                <mui:DataGridTextColumn Header="Country" Binding="{Binding Country, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"/>
                <mui:DataGridTextColumn Header="Phone" Binding="{Binding Phone, UpdateSourceTrigger=PropertyChanged}"/>
                <mui:DataGridTextColumn Header="Email" Binding="{Binding Email, UpdateSourceTrigger=PropertyChanged}"/>
                <mui:DataGridCheckBoxColumn Header="Can Issue Invoices" Binding="{Binding IsMaster, UpdateSourceTrigger=PropertyChanged}"/>
                <DataGridTemplateColumn>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <mui:ModernButton 
							x:Name="viewImageModernButton"
							IconData="M 17,20L 59,20L 59,56L 17,56L 17,20 Z M 20,23L 20,53L 56,53L 56,23L 20,23 Z M 24,51L 30.0833,44.3333L 33.25,47.5L 45.9167,34.8333L 50.6667,39.5833L 54,36L 54,51L 24,51 Z M 30.0833,26.9167C 30.0833,30.4145 27.2478,33.25 23.75,33.25C 23.2033,33.25 22.5061,33.1302 22,33L 22,25L 29.6666,25C 29.7968,25.5061 30.0833,26.3699 30.0833,26.9167 Z "
							 
							ToolTip="view signature image" Command="{Binding ShowImageCommand}"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <mui:ModernButton 
							x:Name="browseImageModernButton" 
							IconData="M 17,20L 59,20L 59,56L 17,56L 17,20 Z M 20,23L 20,53L 56,53L 56,23L 20,23 Z M 24,51L 30.0833,44.3334L 33.25,47.5L 45.9166,34.8334L 50.6666,39.5834L 54,36L 54,51L 24,51 Z M 30.0833,26.9167C 30.0833,30.4145 27.2478,33.25 23.75,33.25C 23.2033,33.25 22.5061,33.1303 22,33L 22,25L 29.6666,25C 29.7968,25.5061 30.0833,26.37 30.0833,26.9167 Z M 28,59C 29.6568,59 31,60.3432 31,62C 31,63.6569 29.6568,65 28,65C 26.3431,65 25,63.6569 25,62C 25,60.3432 26.3431,59 28,59 Z M 48,59C 49.6568,59 51,60.3432 51,62C 51,63.6569 49.6568,65 48,65C 46.3431,65 45,63.6569 45,62C 45,60.3432 46.3431,59 48,59 Z M 38,59C 39.6569,59 41,60.3431 41,62C 41,63.6569 39.6569,65 38,65C 36.3431,65 35,63.6569 35,62C 35,60.3431 36.3431,59 38,59 Z "
							Command="{Binding ShowBrowseCommand}"
							ToolTip="browse for signature image"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

            </DataGrid.Columns>
        </DataGrid>

	   
	</Grid>
</UserControl>
